#pragma once
#include "GameComponent.h"
#include "Messenger.h"
#include "Event_DK_Control_Changed.h"
#include "Timer.h"
#include "DonkeyKongController.h"





class DKCommandListener : public Boon::GameComponent
{
	GAMECOMPONENT( DKCommandListener, GameComponent )

	virtual void OnCreate() 
	{

	}

	virtual void OnStart() 
	{
		if( !GetGameObject().GetComponent<DonkeyKongController>().Empty())
			m_DKController = GetGameObject().GetComponent<DonkeyKongController>().Lock().Get();
		BOON_ASSERT( m_DKController != nullptr )
	}

	virtual void OnEnable() 
	{
		Boon::EventListener listener( this, &DKCommandListener::OnReceiveCommandEvent );
		Boon::Messenger::GetInstance().Register( Event_DK_Control_Changed::ID, listener );
	}

	virtual void OnDisable() 
	{
		Boon::EventListener listener( this, &DKCommandListener::OnReceiveCommandEvent );
		Boon::Messenger::GetInstance().Remove( Event_DK_Control_Changed::ID, listener );
	}


	virtual void Update() 
	{

	}

	virtual void LateUpdate() 
	{

	}


	virtual void OnDestroy() 
	{

	}

	void OnReceiveCommandEvent( const Boon::IMessengerEventStrong& eventData )
	{
		Event_DK_Control_Changed* event = static_cast<Event_DK_Control_Changed*>( eventData.Get() );

		if( event->m_Attack->IsRaised() )
			m_DKController->Attack();


	}

	DonkeyKongController*				m_DKController;
};

